#include<iostream>
#include"compiler.hpp"
#include"runner.hpp"
#include"compile_run.hpp"
#include"../comm/logger.hpp"
#include"../comm/util.hpp"
void testcompiler()
{
    ns_compiler::Compiler::compile("code");
}
void testrunner()
{
    ns_runner::Runner::Run("code",1,1024*20);
}
void testcr()
{
    Json::Value in_value;
    in_value["code"]=R"(#include<iostream>
    int main(){
    std::cout<<"hello world"<<std::endl;
    return 0;
})";
    in_value["cpu_limit"]=1;
    in_value["mem_limit"]=1024*50;
    std::string in_json;
    ns_util::Json_Util::Serialization(in_value,in_json);
    std::string out_json;
    // std::cout<<in_json<<std::endl;
    ns_compile_and_run::CompileRun::start(in_json,out_json);
    Json::Value root;
    ns_util::Json_Util::Deserialization(root,out_json);
    std::cout<<root["status_code"].asInt()<<std::endl;
    std::cout<<root["reason"].asString()<<std::endl;
    if(root["status_code"].asInt()==0)
    {
        std::cout<<root["stdout"].asString()<<std::endl;
        std::cout<<root["stderr"]<<std::endl;
    }
}
int main()
{
    testcr();
    return 0;
}